package com.example.membersteward.enums;

import java.util.ArrayList;
import java.util.List;

public enum Sex {
    O("O","保密"),
    M("M","男"),
    W("W","女");

    private final String code;


    private final String msg;


    Sex(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public static List<String> getOptions() {
        List<String> options = new ArrayList<>();
        for (Sex sex : Sex.values()) {
            options.add(sex.msg);
        }
        return options;
    }

    public static String getCodeByMsg(String msg) {
        for (Sex sex : Sex.values()) {
            if (sex.getMsg().equals(msg)) {
                return sex.getCode();
            }
        }
        return null;
    }

    public static String getMsgByCode(String code) {
        for (Sex sex : Sex.values()) {
            if (sex.getCode().equals(code)) {
                return sex.getMsg();
            }
        }
        return null;
    }
}
